﻿@if (Request.IsAuthenticated)
{
     <text><strong>¡ Hola @User.Identity.Name !</strong>

         <div class="rigth">@Html.ActionLink("Cerrar Sesión", "LogOff", "Account")</div>           
         <div class="rigth"><strong>  |</strong>@Html.ActionLink(" ", "LogOff", "Account", null, htmlAttributes: new { @class = "btnclose", title = "Cerrar Sesión" })</div> 
         <div class = "rigth">@Html.ActionLink("Editar", "Edit", "verify")</div>        
         <strong>  |</strong>@Html.ActionLink(" ", "Edit", "verify", null, htmlAttributes: new { @class = "btnedit2", title = "Editar Perfil" })
            
    </text>
    
    
    
}
else
{

    <div class="rigth"><div class="left">|</div><fb:login-button perms="email,user_checkins" autologoutlink="true" >Entrar con Facebook</fb:login-button>
    <div id="fb-root" style="display:inline; margin-right:0px;"></div></div>
    
    @:<div class="rigth">@Html.ActionLink("Iniciar Sesión ", "LogOn", "Account")</div>
    @:<div class="rigth"><strong>  |</strong>@Html.ActionLink(" ", "LogOn", "Account", null, htmlAttributes: new { @class = "btnlogin", title = "Iniciar Sesión " }) </div>
    @:<div class="rigth">@Html.ActionLink("Regístrese ", "Register", "Account")</div> 
    @:<div class="rigth">@Html.ActionLink(" ", "Register", "Account", null, htmlAttributes: new { @class = "btnregister", title = "Regístrese" }) </div>
    
   
}
<script language="javascript" type="text/javascript">
    // Load the SDK Asynchronously
    (function (d) {
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement('script');
        js.id = id;
        js.async = true;
        js.src = "//connect.facebook.net/es_LA/all.js";
        ref.parentNode.insertBefore(js, ref);
    } (document));

    // Init the SDK upon load
    window.fbAsyncInit = function () {
        FB.init({
            appId: '412456318862572',
            status: true,
            cookie: true,
            xfbml: true,
            oauth: true,
            locale: 'es_LA'
        });
        FB.Event.subscribe('auth.login', function (response) {
            var credentials = { accessToken: response.authResponse.accessToken };
            SubmitLogin(credentials);
        });

        function SubmitLogin(credentials) {
            $.ajax({
                url: "/account/facebooklogin",
                type: "POST",
                data: credentials,
                error: function () {
                    alert("Error al ingresar con tu cuenta de Facebook.");
                },
                success: function () {

                    window.location.reload();

                }

            });
        }

    };
</script>